package com.onetech.adrewards.free.dialogs;

import android.app.Activity;
import android.content.Intent;
import android.text.Html;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.analytics.tracking.android.Fields;
import com.google.analytics.tracking.android.MapBuilder;
import com.google.analytics.tracking.android.Tracker;
import com.onetech.adrewards.free.R;
import com.onetech.adrewards.free.activities.HomeActivity;
import com.zuzu.dialogs.BaseDialog;

public class SuccessDialog extends BaseDialog {
	private TextView newsContent=null;
	
	private Tracker mTracker;
	private String mAction = "";
	private View mOkBtn=null;
	
	private Activity  mContext=null;
	public SuccessDialog(Activity context, String title, String message, String action){
		super(context, title,
				TYPE_NO_BUTTON, R.layout.dialog_success_layout);
		
		mContext=context;
		newsContent=(TextView)findViewById(R.id.successMessage);
		newsContent.setText(Html.fromHtml(message));
		mAction = action;
		mOkBtn=(LinearLayout)findViewById(R.id.btnClose);
		
		mOkBtn.setOnClickListener(this);
	}	
	
	
	
	
	
	@Override
    public void onStart() {
        super.onStart();
        try {
            mTracker.set(Fields.SCREEN_NAME, mContext.getString(R.string.SuccessInviteCodeDialog));            
            mTracker.send(MapBuilder.createAppView().build());            
		} catch (Exception e) {
		}
    }	
	@Override
	public void onClick(View view) {
		int id=view.getId();
		switch (id) {
		case R.id.exitDialogBtn:
			this.dismiss();
			this.cancel();
			if(mAction == "home")
			{
				go2HomePage();
			}
			break;
		case  R.id.btnClose:
			dismiss();
			if(mAction == "home")
			{
				go2HomePage();
			}
	
		default:
			super.onClick(view);
			break;
		}		
	}
	
	public  void go2HomePage(){
		try {
			Intent intent=new Intent(mContext, HomeActivity.class);
			mContext.startActivity(intent);
			
		} catch (Exception e) {
			return;
		}
	}
	
}
